package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.honda.cleanData.baobao.HondaBaoBaoDTO;
import com.baturu.vin.honda.dto.HondaNewCarTypeDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * @Author: jiangxinlei
 * @Time: 2019-04-16 14:21
 **/
public interface HondaTestDAO {

    @Select({"SELECT distinct concat(substr(nfrmpf,1,9),nfrmseqepcstrt) FROM `honda_vin_info`",
            "where length(nfrmpf)=11 and length(nfrmseqepcstrt)=8"})
    List<String> queryAllVinCode();

    @Insert({"<script>insert into tmp_btrid_code_name(btrid,btrPartsName,partsCode,selfPartsName,selfPartsCode) values",
            "<foreach item='item' collection='parts' index='index' open='' separator=',' close=''>",
            "${item}",
            "</foreach>",
            "</script>"})
    void addTmpRelation(@Param("parts")Collection<String> parts);

    @Select({"select distinct npl, nplblk from honda_parts_info"})
    List<HondaBaoBaoDTO> queryAllNpl();

    @Select({"select distinct btrId, vinCode, thireId, partsCode from tmp_newCarType_20190828",
            "WHERE vinstart = #{vinPre11}" ,
            " and start <= #{vinSuf8}" ,
            "and nfrmseqepcend >= #{vinSuf8}",
            })
    List<HondaNewCarTypeDTO> queryCarType(@Param("vinPre11") String vinPre11,@Param("vinSuf8")String vinSuf8);

    @Insert({"<script>insert into honda_parts_desc_cn_newdata(`chejiakaishi`, `chejiajieshu`, `partsCode`, `epcPartsNameEN`, `epcPartsNameCN`, `NPL`, `tuhao`, `NPLBLK`, `xuhao`, `yongliang`)",
            "values",
            "<foreach item='item' collection='dtos' index='index' open='' separator=',' close=''>",
            "(#{item.chejiakaishi},#{item.chejiajieshu},#{item.partsCode},#{item.epcPartsNameEN},#{item.epcPartsNameCN},#{item.npl},#{item.tuhao},#{item.nplblk},#{item.xuhao},#{item.yongliang})",
            "</foreach>",
            "</script>"})
    void insertBaoBao(@Param("dtos") List<HondaBaoBaoDTO> dtos);


}
